#ifndef GPU_BUFFER_MANAGER_H
#define GPU_BUFFER_MANAGER_H

#include "ResourceManager.h"
#include "IndexBuffer.h"
#include "VertexBuffer.h"

namespace Cvekas {

/// Manages index and vertex buffers
class GpuBufferManager : public ResourceManager<GpuBufferPtr>
{
public:
	/// Constructor
	GpuBufferManager(D3DDevicePtr device);
	/// Destructor
	virtual ~GpuBufferManager();

	/// Creates new index buffer
	/// \param name Index buffer name
	/// \param sixteen_bits Will buffer contain 16 bit or 32 bit indices?
	/// \param index_count Number of indices in buffer
	/// \param dynamic Will buffer be dynamic?
	IndexBufferPtr createIndexBuffer(const std::string& name, bool sixteen_bits, uint index_count, bool dynamic);

	/// Creates new vertex buffer
	/// \param name Vertex buffer name
	/// \param format Format
	/// \param vertex_count Number of vertices in buffer
	/// \param dynamic Will buffer be dynamic?
	VertexBufferPtr createVertexBuffer(const std::string& name, VertexFormat format, uint vertex_count, bool dynamic);

	/// Returns existing index buffer
	/// \param name Index buffer name
	IndexBufferPtr getIndexBuffer(const std::string& name);
	
	/// Returns existing index buffer
	/// \param id Index buffer ID
	IndexBufferPtr getIndexBuffer(ResourceId id);

	/// Returns existing vertex buffer
	/// \param name Vertex buffer name
	VertexBufferPtr getVertexBuffer(const std::string& name);

	/// Returns existing vertex buffer
	/// \param id Vertex buffer ID
	VertexBufferPtr getVertexBuffer(ResourceId id);

	/// You shouldn't call this
	void onDeviceLost();
	/// You shouldn't call this
	void onDeviceReset();

private:
	D3DDevicePtr device;
};

typedef boost::shared_ptr<GpuBufferManager> GpuBufferManagerPtr;

} // namespace

#endif